<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>pyokx.rest_handling &mdash; AntBot 0.0.1 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
      <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=eafc0fe6" />

  
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="_static/jquery.js?v=5d32c60e"></script>
        <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="_static/documentation_options.js?v=d45e8c67"></script>
        <script src="_static/doctools.js?v=888ff710"></script>
        <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="pyokx.rest_messages_service" href="pyokx.rest_messages_service.html" />
    <link rel="prev" title="pyokx.redis_structured_streams" href="pyokx.redis_structured_streams.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="index.html" class="icon icon-home">
            AntBot
          </a>
              <div class="version">
                0.0.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="autodocumentation_python.html">autodocumentation_python</a></li>
<li class="toctree-l1"><a class="reference internal" href="firebase_tools.BaseClasses.html">firebase_tools.BaseClasses</a></li>
<li class="toctree-l1"><a class="reference internal" href="firebase_tools.FirestoreClient.html">firebase_tools.FirestoreClient</a></li>
<li class="toctree-l1"><a class="reference internal" href="firebase_tools.authenticate.html">firebase_tools.authenticate</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.dashboard.html">h2o_dashboard.dashboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.pages.documentation_page.html">h2o_dashboard.pages.documentation_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler.html">h2o_dashboard.pages.okx_dashbaord_page.okx_antbot_okx_premium_indicator_handler</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page.html">h2o_dashboard.pages.okx_dashbaord_page.okx_dashboard_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.pages.okx_streams.html">h2o_dashboard.pages.okx_streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.pages.overview_page.html">h2o_dashboard.pages.overview_page</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.util.html">h2o_dashboard.util</a></li>
<li class="toctree-l1"><a class="reference internal" href="h2o_dashboard.wave_auth.html">h2o_dashboard.wave_auth</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.Futures_Exchange_Client.html">pyokx.Futures_Exchange_Client</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.InstrumentSearcher.html">pyokx.InstrumentSearcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.data_structures.html">pyokx.data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Account.html">pyokx.low_rest_api.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.BlockTrading.html">pyokx.low_rest_api.BlockTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Convert.html">pyokx.low_rest_api.Convert</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.CopyTrading.html">pyokx.low_rest_api.CopyTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Earning.html">pyokx.low_rest_api.Earning</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.FDBroker.html">pyokx.low_rest_api.FDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Funding.html">pyokx.low_rest_api.Funding</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Grid.html">pyokx.low_rest_api.Grid</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.MarketData.html">pyokx.low_rest_api.MarketData</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.NDBroker.html">pyokx.low_rest_api.NDBroker</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.PublicData.html">pyokx.low_rest_api.PublicData</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.SpreadTrading.html">pyokx.low_rest_api.SpreadTrading</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Status.html">pyokx.low_rest_api.Status</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.SubAccount.html">pyokx.low_rest_api.SubAccount</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.Trade.html">pyokx.low_rest_api.Trade</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.TradingData.html">pyokx.low_rest_api.TradingData</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.client.html">pyokx.low_rest_api.client</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.consts.html">pyokx.low_rest_api.consts</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.exceptions.html">pyokx.low_rest_api.exceptions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.low_rest_api.utils.html">pyokx.low_rest_api.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.market_data_service.WssMarketDataService.html">pyokx.okx_market_maker.market_data_service.WssMarketDataService</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.market_data_service.model.Instrument.html">pyokx.okx_market_maker.market_data_service.model.Instrument</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.market_data_service.model.MarkPx.html">pyokx.okx_market_maker.market_data_service.model.MarkPx</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.market_data_service.model.OrderBook.html">pyokx.okx_market_maker.market_data_service.model.OrderBook</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.market_data_service.model.Tickers.html">pyokx.okx_market_maker.market_data_service.model.Tickers</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.order_management_service.WssOrderManagementService.html">pyokx.okx_market_maker.order_management_service.WssOrderManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.order_management_service.model.Order.html">pyokx.okx_market_maker.order_management_service.model.Order</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.order_management_service.model.OrderRequest.html">pyokx.okx_market_maker.order_management_service.model.OrderRequest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.position_management_service.WssPositionManagementService.html">pyokx.okx_market_maker.position_management_service.WssPositionManagementService</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.position_management_service.model.Account.html">pyokx.okx_market_maker.position_management_service.model.Account</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition.html">pyokx.okx_market_maker.position_management_service.model.BalanceAndPosition</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.position_management_service.model.Positions.html">pyokx.okx_market_maker.position_management_service.model.Positions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.run_sample_market_maker.html">pyokx.okx_market_maker.run_sample_market_maker</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.settings.html">pyokx.okx_market_maker.settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.BaseStrategy.html">pyokx.okx_market_maker.strategy.BaseStrategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.SampleMM.html">pyokx.okx_market_maker.strategy.SampleMM</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.model.StrategyMeasurement.html">pyokx.okx_market_maker.strategy.model.StrategyMeasurement</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.model.StrategyOrder.html">pyokx.okx_market_maker.strategy.model.StrategyOrder</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.params.ParamsLoader.html">pyokx.okx_market_maker.strategy.params.ParamsLoader</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.risk.RiskCalculator.html">pyokx.okx_market_maker.strategy.risk.RiskCalculator</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.strategy.risk.RiskSnapshot.html">pyokx.okx_market_maker.strategy.risk.RiskSnapshot</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.tests.test_strategy.html">pyokx.okx_market_maker.tests.test_strategy</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.utils.InstrumentUtil.html">pyokx.okx_market_maker.utils.InstrumentUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html">pyokx.okx_market_maker.utils.OkxEnum</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.utils.TdModeUtil.html">pyokx.okx_market_maker.utils.TdModeUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.okx_market_maker.utils.WsOrderUtil.html">pyokx.okx_market_maker.utils.WsOrderUtil</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.redis_structured_reports.html">pyokx.redis_structured_reports</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.redis_structured_streams.html">pyokx.redis_structured_streams</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">pyokx.rest_handling</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.REDIS_STREAM_MAX_LEN"><code class="docutils literal notranslate"><span class="pre">REDIS_STREAM_MAX_LEN</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.assert_okx_account_level"><code class="docutils literal notranslate"><span class="pre">assert_okx_account_level()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.cancel_all_algo_orders_with_params"><code class="docutils literal notranslate"><span class="pre">cancel_all_algo_orders_with_params()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.cancel_all_orders"><code class="docutils literal notranslate"><span class="pre">cancel_all_orders()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.clear_orders_and_positions_for_instrument"><code class="docutils literal notranslate"><span class="pre">clear_orders_and_positions_for_instrument()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.close_all_positions"><code class="docutils literal notranslate"><span class="pre">close_all_positions()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.close_position"><code class="docutils literal notranslate"><span class="pre">close_position()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.fetch_fill_history"><code class="docutils literal notranslate"><span class="pre">fetch_fill_history()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.fetch_initial_data"><code class="docutils literal notranslate"><span class="pre">fetch_initial_data()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.fetch_status_report_for_instrument"><code class="docutils literal notranslate"><span class="pre">fetch_status_report_for_instrument()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.generate_random_string"><code class="docutils literal notranslate"><span class="pre">generate_random_string()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_account_balance"><code class="docutils literal notranslate"><span class="pre">get_account_balance()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_account_config"><code class="docutils literal notranslate"><span class="pre">get_account_config()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_all_algo_orders"><code class="docutils literal notranslate"><span class="pre">get_all_algo_orders()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_all_orders"><code class="docutils literal notranslate"><span class="pre">get_all_orders()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_all_positions"><code class="docutils literal notranslate"><span class="pre">get_all_positions()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_leverage"><code class="docutils literal notranslate"><span class="pre">get_leverage()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_max_avail_size"><code class="docutils literal notranslate"><span class="pre">get_max_avail_size()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_max_order_size"><code class="docutils literal notranslate"><span class="pre">get_max_order_size()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_order_book"><code class="docutils literal notranslate"><span class="pre">get_order_book()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_request_data"><code class="docutils literal notranslate"><span class="pre">get_request_data()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_ticker"><code class="docutils literal notranslate"><span class="pre">get_ticker()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.get_ticker_with_higher_volume"><code class="docutils literal notranslate"><span class="pre">get_ticker_with_higher_volume()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.is_valid_alphanumeric"><code class="docutils literal notranslate"><span class="pre">is_valid_alphanumeric()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.okx_premium_indicator_handler"><code class="docutils literal notranslate"><span class="pre">okx_premium_indicator_handler()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.okx_signal_handler"><code class="docutils literal notranslate"><span class="pre">okx_signal_handler()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.place_algo_order"><code class="docutils literal notranslate"><span class="pre">place_algo_order()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.place_algo_trailing_stop_loss"><code class="docutils literal notranslate"><span class="pre">place_algo_trailing_stop_loss()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.place_order"><code class="docutils literal notranslate"><span class="pre">place_order()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.prepare_dca"><code class="docutils literal notranslate"><span class="pre">prepare_dca()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.prepare_limit_price"><code class="docutils literal notranslate"><span class="pre">prepare_limit_price()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#pyokx.rest_handling.validate_okx_signal_params"><code class="docutils literal notranslate"><span class="pre">validate_okx_signal_params()</span></code></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.rest_messages_service.html">pyokx.rest_messages_service</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.strategy_handling.html">pyokx.strategy_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.AccountTest.html">pyokx.test.AccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.BlockTradingTest.html">pyokx.test.BlockTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.BrokerTest.html">pyokx.test.BrokerTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.ConvertTest.html">pyokx.test.ConvertTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.CopyTradingTest.html">pyokx.test.CopyTradingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.EarningTest.html">pyokx.test.EarningTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.FundingTest.html">pyokx.test.FundingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.GridTest.html">pyokx.test.GridTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.MarketTest.html">pyokx.test.MarketTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.PublicDataTest.html">pyokx.test.PublicDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.SpreadTest.html">pyokx.test.SpreadTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.StackingTest.html">pyokx.test.StackingTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.SubAccountTest.html">pyokx.test.SubAccountTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.TradeTest.html">pyokx.test.TradeTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.TradingDataTest.html">pyokx.test.TradingDataTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.WsPrivateAsyncTest.html">pyokx.test.WsPrivateAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.test.WsPublicAsyncTest.html">pyokx.test.WsPublicAsyncTest</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.websocket_handling.html">pyokx.websocket_handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.ws_clients.WebSocketFactory.html">pyokx.ws_clients.WebSocketFactory</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.ws_clients.WsPprivateAsync.html">pyokx.ws_clients.WsPprivateAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.ws_clients.WsPublicAsync.html">pyokx.ws_clients.WsPublicAsync</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.ws_clients.WsUtils.html">pyokx.ws_clients.WsUtils</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyokx.ws_data_structures.html">pyokx.ws_data_structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="redis_tools.config.html">redis_tools.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="redis_tools.consumers.html">redis_tools.consumers</a></li>
<li class="toctree-l1"><a class="reference internal" href="redis_tools.utils.html">redis_tools.utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="rest_app.html">rest_app</a></li>
<li class="toctree-l1"><a class="reference internal" href="routers.api_keys.html">routers.api_keys</a></li>
<li class="toctree-l1"><a class="reference internal" href="routers.login.html">routers.login</a></li>
<li class="toctree-l1"><a class="reference internal" href="routers.okx.html">routers.okx</a></li>
<li class="toctree-l1"><a class="reference internal" href="routers.okx_authentication.html">routers.okx_authentication</a></li>
<li class="toctree-l1"><a class="reference internal" href="routers.signup.html">routers.signup</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.command_execution.html">shared.command_execution</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.config.html">shared.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.configuration_parser.html">shared.configuration_parser</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.data_processing_utils.html">shared.data_processing_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.file_directory_ops.html">shared.file_directory_ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.logging.html">shared.logging</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.string_dict_utils.html">shared.string_dict_utils</a></li>
<li class="toctree-l1"><a class="reference internal" href="shared.tmp_shared.html">shared.tmp_shared</a></li>
<li class="toctree-l1"><a class="reference internal" href="tradingview_tools.tradingview_widgets.html">tradingview_tools.tradingview_widgets</a></li>
<li class="toctree-l1"><a class="reference internal" href="websocket_app.html">websocket_app</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">AntBot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
      <li class="breadcrumb-item active">pyokx.rest_handling</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/pyokx.rest_handling.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="module-pyokx.rest_handling">
<span id="pyokx-rest-handling"></span><h1>pyokx.rest_handling<a class="headerlink" href="#module-pyokx.rest_handling" title="Link to this heading"></a></h1>
<dl class="py data">
<dt class="sig sig-object py" id="pyokx.rest_handling.REDIS_STREAM_MAX_LEN">
<span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">REDIS_STREAM_MAX_LEN</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1000</span></em><a class="headerlink" href="#pyokx.rest_handling.REDIS_STREAM_MAX_LEN" title="Link to this definition"></a></dt>
<dd><p>THE MODULE NEEDS TO BE UPDATED WITH ENUMS AND STRUCTURED DATA TYPES WHERE APPLICABLE</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>NOTE</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.assert_okx_account_level">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">assert_okx_account_level</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">account_level</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="p"><span class="pre">[</span></span><span class="m"><span class="pre">1</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="m"><span class="pre">2</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="m"><span class="pre">3</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="m"><span class="pre">4</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#assert_okx_account_level"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.assert_okx_account_level" title="Link to this definition"></a></dt>
<dd><p>Validates and sets the OKX account level, ensuring it is one of the acceptable levels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>account_level</strong> (<em>list</em><em>[</em><em>int</em><em>]</em>) – The account level to be validated and set. Acceptable levels are 1, 2, 3, and 4.</p>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>AssertionError</strong> – If the account level is not one of the acceptable levels or if the account level could not be set.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.cancel_all_algo_orders_with_params">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">cancel_all_algo_orders_with_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">algo_orders_list</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Algo_Order" title="pyokx.data_structures.Algo_Order"><span class="pre">Algo_Order</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ordType</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#cancel_all_algo_orders_with_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.cancel_all_algo_orders_with_params" title="Link to this definition"></a></dt>
<dd><p>Cancels all or specific algorithmic orders based on the provided parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>algo_orders_list</strong> (<em>List</em><em>[</em><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Algo_Order" title="pyokx.data_structures.Algo_Order"><em>Algo_Order</em></a><em>]</em><em>, </em><em>optional</em>) – A list of specific algo orders to cancel. If not provided, all algo orders are cancelled.</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to cancel algo orders for, defaults to </p></li>
<li><p><strong>ordType</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of algo order (e.g., ‘trigger’, ‘oco’), defaults to </p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of the algo orders that were successfully cancelled.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.cancel_all_orders">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">cancel_all_orders</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">orders_list</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Order" title="pyokx.data_structures.Order"><span class="pre">Order</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><span class="pre">InstType</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#cancel_all_orders"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.cancel_all_orders" title="Link to this definition"></a></dt>
<dd><p>Cancels all or specific orders based on the provided parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>orders_list</strong> (<em>List</em><em>[</em><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Order" title="pyokx.data_structures.Order"><em>Order</em></a><em>]</em><em>, </em><em>optional</em>) – A list of specific orders to cancel. If not provided, all orders are cancelled.</p></li>
<li><p><strong>instType</strong> (<a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><em>InstType</em></a><em>, </em><em>optional</em>) – The type of instrument to cancel orders for.</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to cancel orders for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of the orders that were successfully cancelled.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>List[<a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Cancelled_Order" title="pyokx.data_structures.Cancelled_Order">Cancelled_Order</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.clear_orders_and_positions_for_instrument">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">clear_orders_and_positions_for_instrument</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#clear_orders_and_positions_for_instrument"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.clear_orders_and_positions_for_instrument" title="Link to this definition"></a></dt>
<dd><p>Clears all orders and positions for a specific instrument.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to clear orders and positions.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.close_all_positions">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">close_all_positions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">positions_list</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Position" title="pyokx.data_structures.Position"><span class="pre">Position</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><span class="pre">InstType</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#close_all_positions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.close_all_positions" title="Link to this definition"></a></dt>
<dd><p>Closes all or specific positions based on the provided parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>positions_list</strong> (<em>List</em><em>[</em><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Position" title="pyokx.data_structures.Position"><em>Position</em></a><em>]</em><em>, </em><em>optional</em>) – A list of specific positions to close. If not provided, all positions are closed.</p></li>
<li><p><strong>instType</strong> (<a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><em>InstType</em></a><em>, </em><em>optional</em>) – The type of instrument to close positions for.</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to close positions for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of the positions that were successfully closed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.close_position">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">close_position</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mgnMode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">posSide</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ccy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">autoCxl</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clOrdId</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#close_position"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.close_position" title="Link to this definition"></a></dt>
<dd><p>Closes a position based on the given parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for the position to be closed.</p></li>
<li><p><strong>mgnMode</strong> (<em>str</em>) – The margin mode for the position (e.g., ‘isolated’, ‘cross’).</p></li>
<li><p><strong>posSide</strong> (<em>str</em><em>, </em><em>optional</em>) – The position side (e.g., ‘long’, ‘short’). Defaults to an empty string.</p></li>
<li><p><strong>ccy</strong> (<em>str</em><em>, </em><em>optional</em>) – The currency used for the position. Defaults to an empty string.</p></li>
<li><p><strong>autoCxl</strong> (<em>str</em><em>, </em><em>optional</em>) – Automatically cancel the position. Defaults to an empty string.</p></li>
<li><p><strong>clOrdId</strong> (<em>str</em><em>, </em><em>optional</em>) – The client order ID. Defaults to an empty string.</p></li>
<li><p><strong>tag</strong> (<em>str</em><em>, </em><em>optional</em>) – A tag for the position. Defaults to an empty string.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The response from the position close request.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.fetch_fill_history">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">fetch_fill_history</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start_timestamp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_timestamp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instType</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#fetch_fill_history"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.fetch_fill_history" title="Link to this definition"></a></dt>
<dd><p>Fetches the fill history for a specific period and instrument type.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start_timestamp</strong> (<em>int</em>) – The starting timestamp for the fill history.</p></li>
<li><p><strong>end_timestamp</strong> (<em>int</em>) – The ending timestamp for the fill history.</p></li>
<li><p><strong>instType</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of instrument for the fill history, defaults to </p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of fill entries.</p>
</dd>
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>AssertionError</strong> – If the requested period is outside the allowed range based on the instrument type.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.fetch_initial_data">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">fetch_initial_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">TD_MODE</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#fetch_initial_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.fetch_initial_data" title="Link to this definition"></a></dt>
<dd><p>Fetches initial data including account balance, account configuration, and instrument status.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>TD_MODE</strong> (<em>str</em>) – The trade mode (e.g., ‘cash’, ‘margin’).</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The instrument ID for which to fetch the data, defaults to </p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A tuple containing simplified balance details, account configuration data, and instrument status report.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.fetch_status_report_for_instrument">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">fetch_status_report_for_instrument</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">TD_MODE</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#fetch_status_report_for_instrument"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.fetch_status_report_for_instrument" title="Link to this definition"></a></dt>
<dd><p>Fetches a comprehensive status report for a specific instrument.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to fetch the status report.</p></li>
<li><p><strong>TD_MODE</strong> (<em>str</em>) – The trade mode (e.g., ‘cash’, ‘margin’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A status report for the instrument, structured according to the InstrumentStatusReport class.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.generate_random_string">
<span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">generate_random_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">length</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">char_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'alphanumeric'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#generate_random_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.generate_random_string" title="Link to this definition"></a></dt>
<dd><p>Generates a random string of the specified length and character type.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>length</strong> (<em>int</em>) – The length of the random string to generate.</p></li>
<li><p><strong>char_type</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of characters to include in the string (‘alphanumeric’, ‘numeric’, or ‘alphabetic’).
Defaults to ‘alphanumeric’.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A random string of the specified length and character type.</p>
</dd>
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>ValueError</strong> – If the length exceeds 32 or if an invalid char_type is specified.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_account_balance">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_account_balance</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_account_balance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_account_balance" title="Link to this definition"></a></dt>
<dd><p>Retrieves the account balance details.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>The account balance data, structured according to the AccountBalanceData class.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_account_config">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_account_config</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_account_config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_account_config" title="Link to this definition"></a></dt>
<dd><p>Retrieves the account configuration details.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>The account configuration data, structured according to the AccountConfigData class.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_all_algo_orders">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_all_algo_orders</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ordType</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_all_algo_orders"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_all_algo_orders" title="Link to this definition"></a></dt>
<dd><p>Fetches all algorithmic orders matching the given criteria from the trading API.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to fetch algo orders for, defaults to </p></li>
<li><p><strong>ordType</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of algo order (e.g., ‘trigger’, ‘oco’), defaults to </p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of algo orders that match the given criteria.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_all_orders">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_all_orders</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_all_orders"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_all_orders" title="Link to this definition"></a></dt>
<dd><p>Fetches all orders matching the given criteria from the trading API.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instType</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of instrument to fetch orders for (e.g., “FUTURES”).</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to fetch orders for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of orders that match the given criteria.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>List[<a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Order" title="pyokx.data_structures.Order">Order</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_all_positions">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_all_positions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><span class="pre">InstType</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_all_positions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_all_positions" title="Link to this definition"></a></dt>
<dd><p>Fetches all positions matching the given criteria from the account API.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instType</strong> (<a class="reference internal" href="pyokx.okx_market_maker.utils.OkxEnum.html#pyokx.okx_market_maker.utils.OkxEnum.InstType" title="pyokx.okx_market_maker.utils.OkxEnum.InstType"><em>InstType</em></a><em>, </em><em>optional</em>) – The type of instrument to fetch positions for (e.g., ‘FUTURES’).</p></li>
<li><p><strong>instId</strong> (<em>str</em><em>, </em><em>optional</em>) – The specific instrument ID to fetch positions for.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of positions that match the given criteria.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_leverage">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_leverage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mgnMode</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_leverage"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_leverage" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_max_avail_size">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_max_avail_size</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tdMode</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_max_avail_size"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_max_avail_size" title="Link to this definition"></a></dt>
<dd><p>Retrieves the maximum available size for trading a specific instrument in a specific trade mode.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to get the maximum available size.</p></li>
<li><p><strong>tdMode</strong> (<em>str</em>) – The trade mode (e.g., ‘cash’, ‘margin’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The maximum available size data, structured according to the MaxAvailSizeData class.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_max_order_size">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_max_order_size</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tdMode</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_max_order_size"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_max_order_size" title="Link to this definition"></a></dt>
<dd><p>Retrieves the maximum order size for a specific instrument and trade mode.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to get the maximum order size.</p></li>
<li><p><strong>tdMode</strong> (<em>str</em>) – The trade mode (e.g., ‘cash’, ‘margin’).</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The maximum order size data, structured according to the MaxOrderSizeData class.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_order_book">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_order_book</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">depth</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_order_book"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_order_book" title="Link to this definition"></a></dt>
<dd><p>Fetches the order book for a specific instrument.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to get the order book.</p></li>
<li><p><strong>depth</strong> (<em>int</em>) – The depth of the order book to fetch.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The order book snapshot, structured according to the Orderbook_Snapshot class.</p>
</dd>
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>ValueError</strong> – If the order book could not be fetched for the specified instrument ID.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_request_data">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_request_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">returned_data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_data_structure</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_request_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_request_data" title="Link to this definition"></a></dt>
<dd><p>Processes the returned data from an API call, mapping it to the specified data structure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>returned_data</strong> (<em>dict</em>) – The raw data returned from the API call.</p></li>
<li><p><strong>target_data_structure</strong> (<em>class</em>) – The class to which the returned data items will be mapped.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of instances of the target data structure class, populated with the returned data.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>List[Any]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_ticker">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_ticker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_ticker"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_ticker" title="Link to this definition"></a></dt>
<dd><p>Retrieves the latest ticker information for a specified instrument.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>instId</strong> (<em>str</em>) – The instrument ID for which to get the ticker information.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The latest ticker information for the specified instrument.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.get_ticker_with_higher_volume">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">get_ticker_with_higher_volume</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed_symbol_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">instrument_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'FUTURES'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">top_n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#get_ticker_with_higher_volume"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.get_ticker_with_higher_volume" title="Link to this definition"></a></dt>
<dd><p>Retrieves the ticker(s) with the highest trading volume for a given seed symbol and instrument type.
Optionally, returns the top N tickers sorted by volume.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>seed_symbol_name</strong> (<em>str</em>) – The base symbol to search for.</p></li>
<li><p><strong>instrument_type</strong> (<em>str</em><em>, </em><em>optional</em>) – The type of instrument (e.g., “FUTURES”). Defaults to “FUTURES”.</p></li>
<li><p><strong>top_n</strong> (<em>int</em><em>, </em><em>optional</em>) – The number of top-volume tickers to return. Defaults to 1.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of tickers, sorted by volume, up to the specified top_n number.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>List[<a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Ticker" title="pyokx.data_structures.Ticker">Ticker</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.is_valid_alphanumeric">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">is_valid_alphanumeric</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_length</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#is_valid_alphanumeric"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.is_valid_alphanumeric" title="Link to this definition"></a></dt>
<dd><p>Validates if the input string is alphanumeric and conforms to the specified maximum length.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>string</strong> (<em>str</em>) – The string to validate.</p></li>
<li><p><strong>max_length</strong> (<em>int</em>) – The maximum allowable length for the string.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>True if the string is alphanumeric and does not exceed the max_length, False otherwise.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.okx_premium_indicator_handler">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">okx_premium_indicator_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">indicator_input</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.OKXPremiumIndicatorSignalRequestForm" title="pyokx.data_structures.OKXPremiumIndicatorSignalRequestForm"><span class="pre">OKXPremiumIndicatorSignalRequestForm</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">dict</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#okx_premium_indicator_handler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.okx_premium_indicator_handler" title="Link to this definition"></a></dt>
<dd><p>Handles incoming premium indicator signals for trading on the OKX platform. It processes the signals,
interprets the trading instructions, manages positions based on the received signals, and executes trading actions.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>indicator_input</strong> (<a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.OKXPremiumIndicatorSignalRequestForm" title="pyokx.data_structures.OKXPremiumIndicatorSignalRequestForm"><em>OKXPremiumIndicatorSignalRequestForm</em></a><em> or </em><em>dict</em>) – The input containing the signals and parameters from the premium indicator.
This can be an instance of PremiumIndicatorSignalRequestForm or a dictionary
that corresponds to the structure of PremiumIndicatorSignalRequestForm.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A dictionary detailing the outcome of the signal processing. If the processing is successful, it includes
the ‘instrument_status_report’ which is a comprehensive status report of the instrument after handling the signal.
In case of an error, it returns a message detailing the issue.</p>
</dd>
</dl>
<p>Process Flow:
1. Validates the input type and converts it into PremiumIndicatorSignalRequestForm if necessary.
2. Extracts and processes trading signals (like Bearish, Bullish, and their respective exit signals) from the input.
3. Determines the trading action (buy/sell) based on the processed signals.
4. Fetches the current positions for the given instrument ID and aligns them with the received signals.
5. Prepares the trading action by setting order sides, clearing prior orders if needed, and handling the ‘red_button’ emergency stop.
6. Passes the processed signal to <cite>okx_signal_handler</cite> for executing the trading operations on the OKX platform.
7. Returns a success message with the ‘instrument_status_report’ or an error message in case of an exception.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>Exception</strong> – Catches and logs any exceptions that occur during the processing of the signal, returning a detailed error message.</p>
</dd>
</dl>
<p>Note:
The major difference between the <cite>okx_signal_handler</cite> and <cite>okx_premium_indicator</cite> is that the latter is
specifically designed to handle premium indicator signals (TV), and it includes additional processing
steps for interpreting the signals and aligning them with the current positions.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.okx_signal_handler">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">okx_signal_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instID</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">usd_order_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">leverage</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order_side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order_type</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_orderbook_limit_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flip_position_if_opposite_side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clear_prior_to_new_order</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">red_button</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sl_trigger_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tp_trigger_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tp_trigger_price_type</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sl_execution_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tp_execution_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sl_trigger_price_type</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trailing_stop_activation_price_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trailing_stop_callback_offset</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dca_parameters</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.DCAInputParameters" title="pyokx.data_structures.DCAInputParameters"><span class="pre">DCAInputParameters</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#okx_signal_handler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.okx_signal_handler" title="Link to this definition"></a></dt>
<dd><p>Handles trading signals for the OKX platform, executing trades based on the specified parameters and current
market conditions.</p>
<p>Overview: 1. Validates and processes input parameters, preparing the trading signal. 2. Checks and manages
current positions based on new signal, potentially flipping positions or clearing orders as configured. 3.
Calculates and sets order parameters such as price and size, leveraging current market data and user preferences.
4. Executes the trading actions (placing/canceling orders, opening/closing positions) on the OKX platform. 5.
Fetches and returns an updated status report of the instrument, reflecting the changes made by the executed signal.</p>
<p>Process Flow: The <cite>okx_signal_handler</cite> function is a complex asynchronous function designed to handle trading
signals for the OKX platform, covering a wide range of trading strategies and actions. Here is a step-by-step
structural and behavioral walkthrough of the main activities within the function, highlighting how it interacts
with other helper functions:</p>
<blockquote>
<div><p>1. <strong>Initialize OKX Signal Input</strong>: It creates an instance of <cite>OKXSignalInput</cite> with all the provided
parameters. This step is crucial for collecting all user inputs regarding the trading signal they wish to
execute.</p>
<p>2. <strong>Pre-validation and Setup</strong>: - Validates trading mode (<cite>TD_MODE</cite>) and position type (<cite>POSSIDETYPE</cite>) to
ensure they are within acceptable parameters. - If the <cite>red_button</cite> parameter is true, the function triggers
emergency actions to close all positions, cancel all orders, and return the status of these actions.</p>
<p>3. <strong>Validate Parameters</strong>: Calls <cite>validate_okx_signal_params</cite> to validate and process input parameters
comprehensively. This includes instrument ID validation, leverage checks, and configuration of additional
parameters like order size, type, and various trading strategies (e.g., stop loss, take profit).</p>
<p>4. <strong>Initial Data Fetching</strong>: Retrieves necessary initial data related to the trading account and the
specific instrument being traded. This might include balance details, account configurations, and the current
status report of the instrument.</p>
<p>5. <strong>Set Leverage</strong>: If leverage is specified, it sets the leverage for the trading account according to the
provided value.</p>
<p>6. <strong>Order and Position Management</strong>: - Checks for existing positions and manages them based on the new
signal. This includes closing positions, canceling orders, or flipping positions if configured to do so by
the user. - If there are no conflicting positions or if the user has opted to clear previous orders and
positions, it proceeds to calculate and set new order parameters.</p>
<p>7. <strong>Order Execution</strong>: - Retrieves current market data (e.g., ticker information) to determine reference
prices for order placement. - Calls <cite>prepare_limit_price</cite> to calculate the appropriate limit price for the
order based on current market conditions and user specifications. - Constructs and sends order requests,
including handling of special order types like take profit, stop loss, and trailing stop losses.</p>
<p>8. <strong>Dollar-Cost Averaging (DCA) Orders</strong>: - If DCA parameters are provided, it prepares and sends multiple
DCA orders based on the specified strategies and market conditions. - Each DCA order is configured with
trigger prices, execution prices, and optional stop loss/take profit parameters.</p>
<p>9. <strong>Final Actions</strong>: - After all trading actions have been attempted, it fetches and returns an updated
status report for the instrument, reflecting the changes made by the executed signal. - Handles exceptions
and errors throughout the process, ensuring that any issues are caught and logged, with appropriate cleanup
actions taken if necessary.</p>
<p>This function encapsulates a comprehensive set of trading strategies and operations, leveraging asynchronous
programming to handle market data fetching, order preparation, and execution in a non-blocking manner. It
demonstrates a complex integration of trading logic, error handling, and user input validation to manage
trading signals on the OKX platform effectively.</p>
<dl class="field-list simple">
<dt class="field-odd">raises Exception<span class="colon">:</span></dt>
<dd class="field-odd"><p>Catches and logs any exceptions that occur during signal handling, providing detailed</p>
</dd>
</dl>
<p>error information.</p>
</div></blockquote>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.place_algo_order">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">place_algo_order</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tdMode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ordType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sz</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ccy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">posSide</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reduceOnly</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpTriggerPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpOrdPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slTriggerPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slOrdPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">triggerPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">orderPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tgtCcy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pxVar</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pxSpread</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">szLimit</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pxLimit</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeInterval</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpTriggerPxType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slTriggerPxType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callbackRatio</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callbackSpread</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">activePx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">triggerPxType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">closeFraction</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quickMgnType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">algoClOrdId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cxlOnClosePos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#place_algo_order"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.place_algo_order" title="Link to this definition"></a></dt>
<dd><p>Places an algorithmic order with detailed parameters.
(as defined by the OKX API documentation, see Orders vs Algo Orders for more details)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for the order.</p></li>
<li><p><strong>tdMode</strong> (<em>str</em>) – The trade mode for the order (e.g., ‘cash’, ‘margin’).</p></li>
</ul>
</dd>
</dl>
<p>… (and so on for other parameters)
:returns: The response from the algorithmic order placement request.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.place_algo_trailing_stop_loss">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">place_algo_trailing_stop_loss</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tdMode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ordType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sz</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">activePx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">posSide</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callbackRatio</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reduceOnly</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">algoClOrdId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cxlOnClosePos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#place_algo_trailing_stop_loss"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.place_algo_trailing_stop_loss" title="Link to this definition"></a></dt>
<dd><p>Places a trailing stop-loss order with detailed parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>str</em>) – The instrument ID for the order.</p></li>
<li><p><strong>tdMode</strong> (<em>str</em>) – The trade mode for the order (e.g., ‘cash’, ‘margin’).</p></li>
</ul>
</dd>
</dl>
<p>… (and so on for other parameters)
:returns: The response from the trailing stop-loss order placement request.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.place_order">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">place_order</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tdMode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ordType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sz</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ccy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clOrdId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">posSide</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">px</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reduceOnly</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tgtCcy</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpTriggerPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpOrdPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slTriggerPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slOrdPx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tpTriggerPxType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">slTriggerPxType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quickMgnType</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stpId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stpMode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">algoClOrdId</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#place_order"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.place_order" title="Link to this definition"></a></dt>
<dd><p>Places an order with the specified parameters.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instId</strong> (<em>Any</em>) – The instrument ID for the order.</p></li>
<li><p><strong>tdMode</strong> (<em>Any</em>) – The trade mode for the order (e.g., ‘cash’, ‘margin’).</p></li>
<li><p><strong>side</strong> (<em>Any</em>) – The side of the order (‘buy’ or ‘sell’).</p></li>
<li><p><strong>ordType</strong> (<em>Any</em>) – The type of the order (e.g., ‘limit’, ‘market’).</p></li>
<li><p><strong>sz</strong> (<em>Any</em>) – The size of the order.</p></li>
</ul>
</dd>
</dl>
<p>… (and so on for other parameters)
:returns: The response from the order placement request.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.prepare_dca">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">prepare_dca</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dca_parameters</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.DCAInputParameters" title="pyokx.data_structures.DCAInputParameters"><span class="pre">DCAInputParameters</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">side</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reference_price</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ccy_contract_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ccy_last_price</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">usd_to_base_rate</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">leverage</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_order_quantity</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_market_order_quantity</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#prepare_dca"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.prepare_dca" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.prepare_limit_price">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">prepare_limit_price</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order_book</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Orderbook_Snapshot" title="pyokx.data_structures.Orderbook_Snapshot"><span class="pre">Orderbook_Snapshot</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">quantity</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">side</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reference_price</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_orderbook_price_offset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#prepare_limit_price"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.prepare_limit_price" title="Link to this definition"></a></dt>
<dd><p>Prepares a limit price based on the order book, quantity, side, reference price, and maximum order book price offset.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>order_book</strong> (<a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.Orderbook_Snapshot" title="pyokx.data_structures.Orderbook_Snapshot"><em>Orderbook_Snapshot</em></a>) – The snapshot of the order book.</p></li>
<li><p><strong>quantity</strong> (<em>Union</em><em>[</em><em>int</em><em>, </em><em>float</em><em>]</em>) – The quantity for which to prepare the limit price.</p></li>
<li><p><strong>side</strong> (<em>str</em>) – The side of the order (‘buy’ or ‘sell’).</p></li>
<li><p><strong>reference_price</strong> (<em>float</em>) – The reference price to base the limit price on.</p></li>
<li><p><strong>max_orderbook_price_offset</strong> (<em>float</em><em>, </em><em>optional</em>) – The maximum allowed offset from the reference price, defaults to </p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The prepared limit price.</p>
</dd>
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>Exception</strong> – If a price in the order book that has enough volume to cover the quantity cannot be found.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="pyokx.rest_handling.validate_okx_signal_params">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pyokx.rest_handling.</span></span><span class="sig-name descname"><span class="pre">validate_okx_signal_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">okx_signal</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="pyokx.data_structures.html#pyokx.data_structures.OKXSignalInput" title="pyokx.data_structures.OKXSignalInput"><span class="pre">OKXSignalInput</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyokx/rest_handling.html#validate_okx_signal_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyokx.rest_handling.validate_okx_signal_params" title="Link to this definition"></a></dt>
<dd></dd></dl>

</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="pyokx.redis_structured_streams.html" class="btn btn-neutral float-left" title="pyokx.redis_structured_streams" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="pyokx.rest_messages_service.html" class="btn btn-neutral float-right" title="pyokx.rest_messages_service" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2024, Ruben Fernandez Carbon.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>